package com.study.jyg.rxjava2study.activity;

import android.os.Bundle;
import com.google.android.material.appbar.AppBarLayout;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.View;
import android.widget.Button;

import com.study.jyg.rxjava2study.R;
import com.study.jyg.rxjava2study.daggerstudy.DaggerTestComponent;
import com.study.jyg.rxjava2study.daggerstudy.TestA;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class TestDaggerActivity extends AppCompatActivity {

    @Inject
    TestA a;
    @BindView(R.id.toolbar)
    Toolbar toolbar;
    @BindView(R.id.appBar)
    AppBarLayout appBar;
    @BindView(R.id.btn1)
    Button btn1;
    @BindView(R.id.btn2)
    Button btn2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test_dagger);
        ButterKnife.bind(this);
        DaggerTestComponent.create().inject(this);

        toolbar.setTitle("Dagger2 Study");
        setSupportActionBar(toolbar);
        toolbar.setNavigationOnClickListener(v -> finish());

        a.tall();
    }

    @OnClick({R.id.btn1, R.id.btn2})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn1:
                a.setB("设置了b的test");
                break;
            case R.id.btn2:
                a.toastB();
                break;
        }
    }


}
